<template>
	<view>
		<form @submit="formSubmit">
			<view class="cu-form-group">
				<view class="action">
					专家简介：
				</view>
				<view class="action">
					
				</view>
			</view>
			<view class="cu-form-group">
				<textarea   placeholder="专家简介" name="description" v-model="expert.description" disabled></textarea>
			</view>
			<view class="cu-form-group">
				<view class="action">
					认证材料：
				</view>
				<view class="action">
					{{imgList.length}}/10
				</view>
			</view>
			<view class="cu-form-group">
				<view class="grid col-4 grid-square flex-sub">
					<view class="bg-img margin-top" v-for="(item,index) in imgList" :key="index" @tap="ViewImage" :data-url="imgList[index]">
					 <image :src="imgList[index]" mode="aspectFill"></image>
					</view>
				</view>
			</view>
			
		</form>
	</view>
</template>

<script>
	var graceChecker = require("../../plugin/graceUI/jsTools/graceChecker.js");
	export default {
		data() {
			return {
				btn_disabled:false,
				btn_type:'',
				btn_loading:false,
				expert:{
					id:'',
					userId:'',
					description:'',
					attachment:'',//附件
				},
				imgList: [],//转换后的图像地址
				tempImgSrc: '',//当前要操作的图片路径，上传或者删除
				expertUrl:this.$config.apiUrl+"/expertController/getExpertInfo",
			};
		},
		onLoad: function (option) { //option为object类型，会序列化上个页面传递的参数
			this.getExpertInfo();
		},
		methods: {
			getExpertInfo : function(){
				this.$http.get(this.expertUrl,{params:{id:this.$store.getters.userid}}).then(res=>{
					 if (res.data.ok) {
						let expert = res.data.data;
						this.expert=expert;
						// console.log(expert);
						//图片
						let photoUrl=[];
						photoUrl=(this.expert.attachment==null || this.expert.attachment=="")?'':this.expert.attachment.split(",");
						for(var i=0;i<photoUrl.length;i++){
							if(photoUrl[i]!='' && photoUrl[i]!=null){
								var imgURL=this.$config.imgUrl+'/img/server/'+photoUrl[i];
								this.imgList.push(imgURL);
								this.tempImgSrc=photoUrl[i];
							}
						}
					}
				}).catch(err => {
					console.log(err);
				});
			},
			ViewImage(e) {
				uni.previewImage({
					urls: this.imgList,
					current: e.currentTarget.dataset.url
				});
			}
			
		}
	}
</script>

<style>
	.cu-form-group .title {
		min-width: calc(4em + 15px);
	}
	
</style>
